//
//  BN_CommentXQViewController.m
//  BabyNow
//
//  Created by 刘泽琛 on 14-5-24.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "BN_CommentXQViewController.h"

@interface BN_CommentXQViewController ()

@end

@implementation BN_CommentXQViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    if (IOS7) {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"详情页";
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"houtui"] style:UIBarButtonItemStylePlain target:self action:@selector(backRootVc)];
    self.navigationItem.leftBarButtonItem = leftItem;
    [self toGroupView];
}

- (void)toGroupView {
    // title
    
    self.contentLabel.text = self.receiveArr[0];
    self.contentLabel.numberOfLines = 0;
    UIFont * tfont = [UIFont fontWithName:@"TrebuchetMS-Bold" size:16];
    self.contentLabel.font = tfont;
    self.contentLabel.lineBreakMode = NSLineBreakByCharWrapping ;
    CGSize size = CGSizeMake(300,10000);
    NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
    CGSize actualsize = [self getTextSize:size disFont:tfont contentStr:self.contentLabel.text contextDic:tdic];
    switch (MAIN_VERSION) {
        case 6:
            self.contentLabel.frame = CGRectMake(10, 10, 300, actualsize.height);
            break;
        default:
            self.contentLabel.frame = CGRectMake(10, 10+64, 300, actualsize.height);
            break;
    }
    NSString *dateStr = self.receiveArr[1];
    self.timeLabel.text = dateStr;
    [self.timeLabel sizeToFit];
    self.timeLabel.frame = CGRectMake(300-self.timeLabel.frame.size.width, CGRectGetMaxY(self.contentLabel.frame)+10, self.timeLabel.frame.size.width, 15);
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.font = [UIFont systemFontOfSize:14];
}

#pragma mark
#pragma mark Action
- (void)backRootVc {
    [self releaseResource];
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark
#pragma mark 资源
- (void)releaseResource {
    // code...
}

- (void)dealloc {
    [self releaseResource];
    NSLog(@"周评详情页面释放...");
}

#pragma mark
#pragma mark 文本高度自适应
// 封装自动撑开高度的方法
- (CGSize)getTextSize:(CGSize)provisionsSize disFont:(UIFont *)font contentStr:(NSString *)contentStr contextDic:(NSDictionary *)contextDic {
    
    CGSize size;
    switch (MAIN_VERSION) {
        case 6:
            size = [contentStr sizeWithFont:font constrainedToSize:provisionsSize lineBreakMode:NSLineBreakByWordWrapping];
            break;
        default:
            size =[contentStr boundingRectWithSize:provisionsSize options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:contextDic context:nil].size;
            break;
    }
    return size;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end
